package com.MoCh.InterfaceDemo1;

import com.MoCh.InterfaceDemo.KeyBoard;

public class Computer {
    public void powerOpen() {
        System.out.println("打开电脑");
    }

    public void powerOff() {
        System.out.println("关闭电脑");
    }

    public void useDevice(USB usb) {
        usb.OpenDevice();
        if(usb instanceof Mouse) {
            Mouse mouse1 = (Mouse) usb;
            mouse1.Click();
        }
        if(usb instanceof Keyboard) {
            Keyboard keyboard1 = (Keyboard) usb;
            keyboard1.Input();
        }
        usb.CloseDevice();
    }

}
